df8d54eea137992b059bbe0ba6d9ce8b46ff4d57,source/org/jasig/portal/channels/CError.java,CError,localRenderXML,#DocumentHandler#,188

Before Change


                // some meaningful error-tolerant output should be generated here.
                LogService.instance().log(LogService.ERROR,"CError::renderXML() : unable to locate a stylesheet");
            } else {
                XSLTResultTarget xmlResult = new XSLTResultTarget(out);
                XSLTProcessor processor = XSLTProcessorFactory.getProcessor (new org.apache.xalan.xpath.xdom.XercesLiaison ());
                if(runtimeData!=null) {
                    processor.setStylesheetParam("baseActionURL", processor.createXString (runtimeData.getBaseActionURL()));
                    processor.setStylesheetParam("showStackTrace", processor.createXString ((new Boolean(showStackTrace)).toString()));
                    processor.setStylesheetParam("allowRefresh", processor.createXString (allowRef));
                    processor.setStylesheetParam("allowReinstantiation", processor.createXString (allowRel));
                }

                processor.process (xmlSource, xslSource, xmlResult);
            }
        } catch (Exception e) { 
            LogService.instance().log(LogService.ERROR,"CError::renderXML() : things are bad. Error channel threw: "+e); 

After Change


	      localRenderXML(out);
    }
    
    private void localRenderXML(DocumentHandler out) {
        // note: this method should be made very robust. Optimally, it should
        // not rely on XSLT to do the job. That means that mime-type dependent
        // output should be generated directly within the method.
        // For now, we'll just do it the usual way.


        // XML of the following type is generated:
        // <error code="$errorID">
        //  <message>$message</messag>
        //  <channel>
        //   <id>$channelID</id>
        //   <name>$channelName</name>
        //  </channel>
        //  <exception code="N">
        //   <resource><uri/><description/></resource>
        //   <timeout value="N"/>
        //  </exception>
        // </error>
        //
        // Note that only two exceptions have detailed elements associated with them.
        // In the future, if the information within exceptions is expanded, it should be
        // placed into this XML for the CError UI to give user a proper feedback.

        Document doc = new org.apache.xerces.dom.DocumentImpl();
        Element errorEl=doc.createElement("error");
        errorEl.setAttribute("code",Integer.toString(errorID));
        if(str_message!=null) {
            Element messageEl=doc.createElement("message");
            messageEl.appendChild(doc.createTextNode(str_message));
            errorEl.appendChild(messageEl);
        }

        if(str_channelID!=null) {
            Element channelEl=doc.createElement("channel");
            Element idEl=doc.createElement("id");
            idEl.appendChild(doc.createTextNode(str_channelID));
            channelEl.appendChild(idEl);

            // determine channel name
            if(portcs!=null) {
                String chName=(portcs.getUserLayoutManager()).getNodeName(str_channelID);
                if(chName!=null) {
                    Element nameEl=doc.createElement("name");
                    nameEl.appendChild(doc.createTextNode(chName));
                    channelEl.appendChild(nameEl);
                }
                errorEl.appendChild(channelEl);
            }
        }

        // if the exception has been generated
        if(channelException!=null) {
            Element excEl=doc.createElement("exception");
            String m;
            if((m=channelException.getMessage())!=null) {
                Element emEl=doc.createElement("message");
                emEl.appendChild(doc.createTextNode(m));
                excEl.appendChild(emEl);
            }

            Element stEl=doc.createElement("stack");
            java.io.StringWriter sw=new java.io.StringWriter();
            channelException.printStackTrace(new java.io.PrintWriter(sw));
            sw.flush();
            stEl.appendChild(doc.createTextNode(sw.toString()));
            excEl.appendChild(stEl);


            if(channelException instanceof PortalException) {
                PortalException pe=(PortalException) channelException;
                // the Error channel has been invoked as a result of some other
                // channel throwing a PortalException.

                // determine which type of an exception is it
                excEl.setAttribute("code",Integer.toString(pe.getExceptionCode()));

                // now specific cases for exceptions containing additional information
                if(pe instanceof ResourceMissingException) {
                    ResourceMissingException rme=(ResourceMissingException) pe;
                    Element resourceEl=doc.createElement("resource");
                    Element uriEl=doc.createElement("uri");
                    uriEl.appendChild(doc.createTextNode(rme.getResourceURI()));
                    resourceEl.appendChild(uriEl);
                    Element descriptionEl=doc.createElement("description");
                    descriptionEl.appendChild(doc.createTextNode(rme.getResourceDescription()));
                    resourceEl.appendChild(descriptionEl);
                    excEl.appendChild(resourceEl);
                } else if(pe instanceof InternalTimeoutException) {
                    Long v=((InternalTimeoutException)pe).getTimeoutValue();
                    if(v!=null) {
                        Element timeoutEl=doc.createElement("timeout");
                        timeoutEl.setAttribute("value",v.toString());
                    }
                }
            } else {
                // runtime exception generated by the channel
                excEl.setAttribute("code","-1");
            }
            errorEl.appendChild(excEl);
        }
        doc.appendChild(errorEl);

        // figure out if we allow for refresh/reload
        String allowRef="true";
        String allowRel="true";
        if(str_channelID==null) {
            allowRel=allowRef="false";
        } else {
            if(channelException!=null && (channelException instanceof PortalException)) {
                if(errorID==SET_STATIC_DATA_EXCEPTION || !((PortalException)channelException).allowRefresh())
                    allowRef="false";
                if(!((PortalException)channelException).allowReinstantiation())
                    allowRel="false";
            }
        }

        // debug block
        try {
            java.io.StringWriter outString = new java.io.StringWriter ();
            org.apache.xml.serialize.OutputFormat format=new org.apache.xml.serialize.OutputFormat();
            format.setOmitXMLDeclaration(true);
            format.setIndenting(true);
            org.apache.xml.serialize.XMLSerializer xsl = new org.apache.xml.serialize.XMLSerializer (outString,format);
            xsl.serialize (doc);
            LogService.instance().log(LogService.DEBUG,outString.toString());
        } catch (Exception e) {
            LogService.instance().log(LogService.DEBUG,e);
        }
        // end of debug block

        try {
            Hashtable stylesheetParams = new Hashtable(4);
            stylesheetParams.put("baseActionURL", runtimeData.getBaseActionURL());
            stylesheetParams.put("showStackTrace", new Boolean(showStackTrace).toString());
            stylesheetParams.put("allowRefresh", allowRef);
            stylesheetParams.put("allowReinstantiation", allowRel);
            XSLT.transform(doc, new URL(sslLocation), out, stylesheetParams, runtimeData.getBrowserInfo());
            
/*            XSLTInputSource xmlSource = new XSLTInputSource (doc);
            XSLTInputSource xslSource = set.getStylesheet(portcs.getHttpServletRequest());